package com.ruoyi.eam.service.impl;

import java.util.List;

import com.ruoyi.eam.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.eam.doman.EamReturnH;
import com.ruoyi.eam.service.IEamReturnHService;

import javax.annotation.Resource;

/**
 * 资产退还Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-09
 */
@Service
public class EamReturnHServiceImpl implements IEamReturnHService 
{
    @Resource
    private EamReturnHMapper eamReturnHMapper;

    @Resource
    private UserMapper userMapper;

    @Resource
    private EamReturnDMapper eamReturnDMapper;

    @Resource
    private EamAssetMapper eamAssetMapper;

    @Resource
    private EamLocationMapper eamLocation;

    @Resource
    private DeptMapper deptMapper;

    @Resource
    private EamTypeMapper eamTypeMapper;

    /**
     * 查询资产退还
     * 
     * @param returnId 资产退还主键
     * @return 资产退还
     */
    @Override
    public EamReturnH selectEamReturnHByReturnId(Long returnId)
    {
        return eamReturnHMapper.selectEamReturnHByReturnId(returnId);
    }

    /**
     * 查询资产退还列表
     * 
     * @param eamReturnH 资产退还
     * @return 资产退还
     */
    @Override
    public List<EamReturnH> selectEamReturnHList(EamReturnH eamReturnH)
    {
        List<EamReturnH> list = eamReturnHMapper.selectEamReturnHList(eamReturnH);
        if(list.size() > 0){
            for (EamReturnH returnH : list) {
                returnH.setU(userMapper.selectUserByUserId(returnH.getUsePerson()));
                returnH.setEamReturnD(eamReturnDMapper.selectEamReturnDByAssetId(returnH.getReturnCode()));
                returnH.setEamLocation(eamLocation.selectEamLocationByLocationId(returnH.getEamReturnD().getLocationId()));
                returnH.setEamAsset(eamAssetMapper.selectEamAssetByAssetId(returnH.getEamReturnD().getAssetId()));
                returnH.setDept(deptMapper.selectDeptByDeptId(returnH.getU().getDeptId()));
                returnH.setEamType(eamTypeMapper.selectEamTypeByTypeId(returnH.getEamAsset().getTypeId()));
            }
        }
        return list;
    }

    /**
     * 新增资产退还
     * 
     * @param eamReturnH 资产退还
     * @return 结果
     */
    @Override
    public int insertEamReturnH(EamReturnH eamReturnH)
    {
        return eamReturnHMapper.insertEamReturnH(eamReturnH);
    }

    /**
     * 修改资产退还
     * 
     * @param eamReturnH 资产退还
     * @return 结果
     */
    @Override
    public int updateEamReturnH(EamReturnH eamReturnH)
    {
        return eamReturnHMapper.updateEamReturnH(eamReturnH);
    }

    /**
     * 批量删除资产退还
     * 
     * @param returnIds 需要删除的资产退还主键
     * @return 结果
     */
    @Override
    public int deleteEamReturnHByReturnIds(Long[] returnIds)
    {
        return eamReturnHMapper.deleteEamReturnHByReturnIds(returnIds);
    }

    /**
     * 删除资产退还信息
     * 
     * @param returnId 资产退还主键
     * @return 结果
     */
    @Override
    public int deleteEamReturnHByReturnId(Long returnId)
    {
        return eamReturnHMapper.deleteEamReturnHByReturnId(returnId);
    }
}
